﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OF.Component.BLL;
using OF.Component.Model;
using OF.Component.Base;
using OF.Utility;

namespace OpSystem.manage.ajax
{
    public partial class AjaxDelete : OpBasePage
    {
        private string strGuid = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            switch (Type)
            {

                case "dictionaryclass":
                    DelBaseDictionaryClass();
                    break;
                case "dictionary":
                    DelBaseDictionary();
                    break;
                case "authoritysystem":
                    DelAuthoritySystem();
                    break;
                case "authorityrole":
                    DelAuthorityRole();
                    break;
                case "authoritymenu":
                    DelAuthorityMenu();
                    break;
                case "listpage":
                    DelCustomListPageList();
                    break;
            }
            if (strGuid != "")
            {
                //OF.Common.BaseOperationLog.Insert_OperationLog(strGuid, OpUserInfo.OpUserID, OpUserInfo.OpUserName, "删除");
            }
        }


        #region"系统管理"

        /// <summary>
        /// 删除字典分类
        /// </summary>
        private void DelBaseDictionaryClass()
        {
            string[] strFIDAll = FID.Split('|');
            foreach (string strID in strFIDAll)
            {
                if (strID == "") continue;
                BaseDictionaryClassInfo info = BaseDictionaryClassOperate.GetByID(EConvert.ToInt(strID));
                if (info != null)
                {
                    strGuid = info.OperationID;
                    info.IsActive = 0;
                    info.UpdateTime = DateTime.Now;
              
                    BaseDictionaryClassOperate.Update(info);
                }
            }
        }

        /// <summary>
        /// 删除字典
        /// </summary>
        private void DelBaseDictionary()
        {
            string[] strFIDAll = FID.Split('|');
            foreach (string strID in strFIDAll)
            {
                if (strID == "") continue;
                if (strID == "") continue;
                BaseDictionaryInfoInfo info = BaseDictionaryInfoOperate.GetByID(EConvert.ToInt(strID));
                if (info != null)
                {
                    strGuid = info.OperationID;
                    info.IsActive = 0;
                    info.UpdateTime = DateTime.Now;
                    BaseDictionaryInfoOperate.Update(info);
                }
            }
        }
        /// <summary>
        /// 删除系统
        /// </summary>
        private void DelAuthoritySystem()
        {
            string[] strFIDAll = FID.Split('|');
            foreach (string strID in strFIDAll)
            {
                if (strID == "") continue;
                if (strID == "") continue;
                AuthoritySystemInfo info = AuthoritySystemOperate.GetByID(EConvert.ToInt(strID));
                if (info != null)
                {
                    strGuid = info.OperationID.ToString();
                    info.IsActive = 0;
                    info.UpdateTime = DateTime.Now;
                    AuthoritySystemOperate.Update(info);
                }
            }
        }

        /// <summary>
        /// 删除角色管理
        /// </summary>
        private void DelAuthorityRole()
        {
            string[] strFIDAll = FID.Split('|');
            foreach (string strID in strFIDAll)
            {
                if (strID == "") continue;
                if (strID == "") continue;
                AuthorityRoleInfo info = AuthorityRoleOperate.GetByID(EConvert.ToInt(strID));
                if (info != null)
                {
                    strGuid = info.OperationID.ToString();
                    info.IsActive = 0;
                    info.UpdateTime = DateTime.Now;
                    AuthorityRoleOperate.Update(info);
                }
            }
        }
            /// <summary>
        /// 删除角色管理
        /// </summary>
        private void DelAuthorityMenu()
        {
            string[] strFIDAll = FID.Split('|');
            foreach (string strID in strFIDAll)
            {
                if (strID == "") continue;
                if (strID == "") continue;
                AuthorityMenuInfo info = AuthorityMenuOperate.GetByID(EConvert.ToInt(strID));
                if (info != null)
                {
                    strGuid = info.OperationID.ToString();
                    info.IsActive = 0;
                    info.UpdateTime = DateTime.Now;
                    AuthorityMenuOperate.Update(info);
                }
            }

        }
              /// <summary>
        /// 删除角色管理
        /// </summary>
        private void DelCustomListPageList()
        {
            //string[] strFIDAll = FID.Split('|');
            //foreach (string strID in strFIDAll)
            //{
            //    if (strID == "") continue;
            //    if (strID == "") continue;
            //    BaseCustomListPageInfo info = BaseCustomListPageOperate.GetByID(EConvert.ToInt(strID));
            //    if (info != null)
            //    {
            //        info.IsActive = 0;
            //        info.UpdateTime = DateTime.Now;
            //        BaseCustomListPageOperate.Update(info);
            //    }
            //}

        }
        
        #endregion

        /// <summary>
        /// ID
        /// </summary>
        private string FID
        {
            get
            {
                if (!string.IsNullOrEmpty(Request.Params["idall"]))
                {
                    return Convert.ToString(Request.Params["idall"]);
                }
                else
                {
                    return "";
                }
            }
        }

        /// <summary>
        /// 操作类别
        /// </summary>
        private string Type
        {
            get
            {
                if (!string.IsNullOrEmpty(Request.Params["ty"]))
                {
                    return Convert.ToString(Request.Params["ty"]);
                }
                else
                {
                    return "";
                }
            }
        }
    }
}